<style type="text/css">
.error{
	display:block;
	width:240px;
	}
</style>

<?php 
$CI =& get_instance();
$CI->load->library("admin/admin_header_lib");
$CI->admin_header_lib->display_header_element(array("script"=>array("jquery-1.4.2","jquery.validate","jquery.metadata")));
$CI->admin_header_lib->display_header();

$CI->load->library('admin/admin_sidebar_lib');
$CI->admin_sidebar_lib->display_sidebar();

?>
<script type="text/javascript">
function confirmation(){
   
    var total='';
  
    for(var i=0; i < document.print_colours_delete.papercolours.length; i++){
       
        if(document.print_colours_delete.papercolours[i].checked)
        {
            total +=document.print_colours_delete.papercolours[i].value + "\n";
        
        }
    }
        if(total==""){
        alert("Please select print colour");
        return false;
        }
        else{
            if(confirm('Are you sure to delete ?'))
               document.print_colours_delete.submit();
            else
                return false;
        
        }
  
 
    
}

function setdefault()
{
	var total=  0;
  
    for(var i=0; i < document.print_colours_delete.papercolours.length; i++){
       
        if(document.print_colours_delete.papercolours[i].checked)
        {
            //total +=document.print_colours_delete.papercolours[i].value + "\n";
			total++;
			
        
        }
    }
        if(total==""){
        alert("Please select print colour");
        return false;
        }
		else if(total > 1)
		{
			alert("Please select at least one");
       		return false;	
		}
        else{
               //document.print_colours_delete.submit();
			   $('#print_colours_delete').attr('action','<?php echo  site_url('admin/print_colours/setdefault') ?>');
			   document.print_colours_delete.submit();
			   //return true
			   //alert($('#print_colours_delete').attr('action'));
			   return true;
        }
  
}

</script>


<script language="javascript">
function Move_up(str){
    $.ajax({
   type: "POST",
   url: "<?php echo  site_url('admin/print_colours/move') ?>",
   data: "id="+str,
   success: function(msg){
    
   window.location='<?php site_url('admin/print_colours/') ?>';
    // alert( "Data Saved: " + msg );
   }
 });

    
    
   

}

</script>






<script type="text/javascript">
	$(document).ready(function(){	
    
    $.metadata.setType("attr", "validate");


//	$("#print_colours_delete").validate();
	
	$("#print_colours_add_edit").validate({
		rules: {
			papercolour_title: "required"
		},
		messages: {
			papercolour_title: "Please enter  print colours"
			
		}
	});
	  
    
});
</script>

<style type="text/css">
.block { display: block; }
form.print_colours_delete label.error { display: none; }

</style>

<div class="admin_right">
<!--End  List-->


<?php
$attributes = array('name' => 'print_colours_delete', 'id' => 'print_colours_delete','class' =>'print_colours_delete');
 echo form_open('admin/print_colours/delete',$attributes);?>
 <table class="grid_tbl" width="100%">
       <tr><th colspan="4"><h2 class="head02">print colours</h2></th>
       </tr>
        <?php if(!empty($paper_colours)): ?>
        <?php foreach($paper_colours as $key=>$value): ?>
        <tr>
        <?php //echo $value['papercolour_id'] ?>
      	<td><?php echo $value['papercolour_title'] ?></td>
        <td> 
        <a class="red13" href="#" onclick="Move_up(<?php echo $value['papercolour_id']?>)">Move Up</a>
        </td>
        <td align="right">  
        <input type="checkbox" name="papercolours[]" id="papercolours" class="papercolours"  value="<?php echo $value['papercolour_id']?>" />
        </td>
        <td align="right">
        <a class="red13"  href="<?php echo site_url('admin/print_colours/index/'.$page.'/'.$value['papercolour_id']); ?>">Edit</a>
        </td>
		</tr>
        
        <?php endforeach;
 			 endif; ?>
       <tr><td><a href="javascript:void(0);" id="set_default" onclick="return setdefault();">Set as Default</a></td>
       <td colspan="3" align="right"><input type="submit" onclick=" return confirmation()" name="delete" value="Delete"/>
       <?php //echo form_error('papercolours[]');?>
       </td>
       </tr>
       <td colspan="4" style="border:0;" >
  <span id="ajaxcontent">
<?php //$this->load->view('list') ?>
</span>
        <label for="papercolours[]" class="error">Please select print colours.</label>
       </td>
       </tr>
 </table>
 </form>

 <div class="pagination">
	<?php echo $pagination; ?>
    <div class="clear"></div>
</div>
<div style="height:5px;"></div>
<div class="line6"></div>
 <table width="100%">
        
		<tr><td><p class="redTxt15px">Add/Edit print colours : </p></td><td></tr>
        <tr><td height="5"></td></tr>
        <tr><td><p class="white_bold">print colours: <span class="normal">(required)</span></p></td></tr>
        <tr><td height="5"></td></tr>
        <tr><td>
	<?php	$attributes = array('name' => 'print_colours_add_edit', 'id' => 'print_colours_add_edit','class' =>'print_colours_add_edit');?>
          <?php echo  form_open('admin/print_colours/action',$attributes); ?>
         <input type="hidden" name="page" value="<?php echo $page; ?>" />
        <input type="hidden" name="papercolour_id" value="<?php echo $edit['papercolour_id'] ?>" />
		
        <input type="text" style="width:250px;"  name="papercolour_title" id="papercolour_title"  value="<?php echo $edit['papercolour_title'] ?>" />
		<div for="papercolour_title" generated="true" class="error" style="display: none;">Please enter  print colours</label>
		
		
		
        <?php echo form_error('papercolour_title'); ?>
		
        </td></tr>
        <tr><td style="border-bottom:1px solid  #262B30; padding-bottom:5px;"></td></tr>
		<tr><td height="5"></td></tr>
		<tr><td >
         
        <input type="submit" name="my_submit"  value="submit<?php //if(!empty($paper_colours_detail)){echo 'edit';}else{echo 'add';}?>"/>
        </form>  
		</tr>
        </tr>
         </table>
<?php /*  end of all  content  */ ?>


</div><!-- page noright -->


<?php  $this->load->view(TEMPLATE_NAME.'/admin/footer');?>